import pandas as pd
import numpy as np
import csv
# import datagenaration
from vm_state_genarate import *
from Node_LP import LP,Machine
p=open("vm_state.csv")
f = open("lp_state.csv", encoding="utf-8")
# f=pd.read_csv("jobs.csv")
lp_st=pd.read_csv(f)
vm_st=pd.read_csv(p)

lp_state = lp_st.apply(pd.to_numeric, errors='coerce')
vm_state = vm_st.apply(pd.to_numeric, errors='coerce')


for i in range(100):

    lp_idx = i
    locals()["lp" + str(i)] = LP(np.array(lp_state['vm_loc%s' % i]), np.array(lp_state['cpu%s' % i]),
                                 np.array(lp_state['mem%s' % i]), lp_idx)
for j in range(9):
    vm_idx=j
    locals()["vm" + str(j)] = Machine( np.array(vm_state['cpu_percent%s' % j]),
                                 np.array(vm_state['mem_percent%s' % j]), np.array(vm_state['lp_number%s' % j]),vm_idx,locals()["order" + str(j)])
# print(vm0.cpu_percent.shape)
# numbers=[vm0.cpu_percent[0],vm1.cpu_percent[1],vm2.cpu_percent[2],vm3.cpu_percent[3]]
# print(vm_state)
# print(np.sum(vm1.order,axis=1))
# print(vm1.lp_number[0])
# for j in range(9):
#     machine_idx=j
#     cpu_percent=
# index=[]
# for i in range(len(numbers)):
#     index.append(numbers.index(sorted(numbers)[i]))
# print(numbers)
# print(sorted(numbers))
# print(index)
# print(numbers[3])


